// src/db.ts
import { DataSource } from 'typeorm';
import { SysUser } from './entity/SysUser'; // 假设你已经创建了User实体
import { AigcTask } from './entity/AigcTask'; // 假设你已经创建了User实体
import { TaskScoring } from './entity/TaskScoring';
import { AttributionPoint } from './entity/AttributionPoint';

export const AppTestDataSource = new DataSource({
    type: "mysql",
    host: process.env.TEST_DB_HOST,
    port: Number(process.env.TEST_DB_PORT),
    username: process.env.TEST_DB_USERNAME,
    password: process.env.TEST_DB_PASSWORD,
    database: process.env.TEST_DB_DATABASE,
    entities: [SysUser, AigcTask, TaskScoring, AttributionPoint],
    synchronize: false,
});

AppTestDataSource.initialize()
    .then(() => {
        console.log("Test Data Source has been initialized!" + process.env.DB_HOST);
    })
    .catch((err) => {
        console.error("Test Error during Data Source initialization", err);
    });